package math
{
	
	import flash.display.DisplayObject;
	import flash.display.Sprite;
	import flash.events.*;
	import flash.geom.*;
	
	public class Circle2 extends Sprite
	{
		private var container:Sprite=new Sprite();//创建容器 
		private var speedx:Number=0;
		private var speedy:Number=0;
		private var circleImage:CircleImage;
		private var begin:Boolean=false;
		
		public function Circle2(centerX:Number, centerY:Number, _stage:DisplayObject)
		{
			addChild(container);
			container.x=centerX;
			container.y=centerY;
			container.z=0;
			
			circleImage=new CircleImage(9,600);//创建一个我们自定义类对象
			circleImage.loadXML("./xml/config.xml");//加载外部的xml
			
			circleImage.addEventListener("Finish",onComplete);
			circleImage.addEventListener("onClick",clickHandler);
			
			container.addChild(circleImage);
			circleImage.contain=container;
			
			
			addEventListener(Event.ENTER_FRAME,Run);
			_stage.addEventListener(MouseEvent.MOUSE_MOVE,onMove);
		}
		
		private function onComplete(event:Event):void
		{
			circleImage.creatEffect();
			begin=true;
		}
		
		//当鼠标与中心点产生一段距离的时候
		private function onMove(event:MouseEvent):void
		{
			speedx=(mouseX-container.x)*0.01;
			speedy=(mouseY-container.y)*0.01;
			
		}
		
		private function Run(event:Event):void
		{
			if (begin)
			{
				container.rotationY+=speedx;
				container.rotationX+=speedy;
				circleImage.sortZ();
			}
		}
		
		private function clickHandler(event:Event):void
		{
			trace("www");
			
		}
		
	}
}